package com.example.hello.service.controller;

import java.util.LinkedList;
import java.util.List;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.example.hello.service.api.model.User;

@RestController
public class UserController {
	
	@RequestMapping(value="/users/{id}",method=RequestMethod.GET)
	public User getUserById(@PathVariable Long id){
		User user = new User();
		user.setId(id);
		user.setUserName("测试");
		return user;
	}

	@RequestMapping(value="/users",method=RequestMethod.GET)
	public List<User> getAllUser(@RequestParam List<Long> ids){
		if(ids == null || ids.isEmpty()){
			return null;
		}else{
			List<User> users = new LinkedList<>();
			for(Long id : ids){
				User user = new User();
				user.setId(id);
				user.setUserName("测试");
				users.add(user);
			}
			return users;
		}
	}
}
